package gui 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	/**
	 * ...
	 * @author Dmitriy Gaiduk
	 */
	public class LoaderIndicator extends Sprite
	{
		public var radius:Number = 8;
		public var circleSize:Number = 4;
		
		public function LoaderIndicator(loaderRadius:Number = 8, circSize:Number = 4) 
		{
			radius = loaderRadius;
			circleSize = circSize;
			addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
		}
		
		private function handleAddedToStage(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
			initIndicator();
		}
		
		private function initIndicator():void 
		{
			var circleCount:int = 8;
			var posX:Number;
			var posY:Number;
			var startX:Number = 0;
			var startY:Number = 0;
			var preloaderPart:MovieClip = new PreloaderPartAnim();
			var angle:Number;
			var angleStep:Number = 360 / circleCount;
			var piDiv180:Number = Math.PI / 180;
			
			var frameStep:int = preloaderPart.totalFrames / circleCount;
			for (var i:int = 0; i < circleCount; i++)
			{
				angle = (i * angleStep) * piDiv180;
				posX = startX + radius * Math.cos(angle);
				posY = startX + radius * Math.sin(angle);
				preloaderPart = new PreloaderPartAnim();
				preloaderPart.width = circleSize;
				preloaderPart.height = circleSize;
				preloaderPart.gotoAndPlay((i + 1) * frameStep);
				preloaderPart.x = posX;
				preloaderPart.y = posY;
				addChild(preloaderPart);
			}
			//this.x = (parent.width - this.width) * 0.5;
			//this.y = (parent.height - this.height) * 0.5;
		}
		
		public function setPercent(percent:Number):void
		{
			
		}
		
		public function update():void
		{
			
		}
		
	}

}